package com.example.component;

import com.example.travelcomponentdemo.R;
import com.example.travelcomponentdemo.SendNotification;

import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.support.v4.app.NotificationCompat;

public class SendNotificationUtil {
	public static void sendNotification(String message, String title, Context ctx, Class<?> c) {
		// Prepare intent which is triggered if the
	    // notification is selected
	    Intent intent = new Intent(ctx, c);
	    PendingIntent pIntent = PendingIntent.getActivity(ctx, 0, intent, 0);

	    // Build notification
	    // Actions are just fake
	    Notification noti = new NotificationCompat.Builder(ctx)
	        .setContentTitle(title)
	        .setContentText(message).setSmallIcon(R.drawable.icon)
	        .setContentIntent(pIntent)
	        .build();
	    NotificationManager notificationManager = (NotificationManager) ctx.getSystemService(ctx.NOTIFICATION_SERVICE);
	    // hide the notification after its selected
	    noti.flags |= Notification.FLAG_AUTO_CANCEL;

	    notificationManager.notify(0, noti);
	}
}
